﻿@using FormBuilder.Components.Drag
@using FormBuilder.Helpers

@inject ITranslationHelper translationHelper

<DraggableFormElement IsEditModeEnabled=@IsEditModeEnabled ParentContext="@ParentContext" Context="@Context" TDialog="FormAnchorDialog" TRecord="FormAnchorRecord" Record="@Value">
    <Children>
        @if(Value.ActAsButton)
        {
            <button id="@CssId" class="@BtnClass" 
                    @onclick=@(async (e) => await Navigate())>
                @translationHelper.Translate(Value, IsEditModeEnabled ? "Please provide a name" : string.Empty, !IsEditModeEnabled)
            </button>
        }
        else
        {
            <a href="#"
                id="@CssId"
                class="@AnchorClass"
                @onclick:stopPropagation="true" 
                @onclick:preventDefault="true" 
                @onclick="@(async (e) => await Navigate())">@translationHelper.Translate(Value, IsEditModeEnabled ? "Please provide a name" : string.Empty, InputData, !IsEditModeEnabled)</a>
        }
    </Children>
</DraggableFormElement>